fix(project): validate runtimeVersion on CodeZip runtimes - #1972
Merged
Conversation
notgitika
had a problem deploying
to
e2e-testing
August 11, 2026 15:38 — with
GitHub Actions
Failure
notgitika
force-pushed
the
feat/project-build-synth
branch
from
August 11, 2026 19:03
305bf56 to
639227f
Compare
notgitika
force-pushed
the
fix/codezip-runtime-version
branch
from
August 12, 2026 19:54
4c2ac79 to
1ed88a7
Compare
notgitika
had a problem deploying
to
e2e-testing
August 12, 2026 19:54 — with
GitHub Actions
Failure
tejaskash
force-pushed
the
feat/project-build-synth
branch
from
August 12, 2026 20:24
78097a8 to
0b2da99
Compare
notgitika
force-pushed
the
feat/project-build-synth
branch
from
August 13, 2026 15:25
0b2da99 to
05c244e
Compare
notgitika
force-pushed
the
fix/codezip-runtime-version
branch
from
August 13, 2026 15:29
1ed88a7 to
1ac4641
Compare
notgitika
had a problem deploying
to
e2e-testing
August 13, 2026 15:29 — with
GitHub Actions
Failure
notgitika
force-pushed
the
fix/codezip-runtime-version
branch
from
August 13, 2026 18:06
1ac4641 to
86d59df
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #1972 +/- ##
=========================================
Coverage 97.13% 97.13%
=========================================
Files 386 386
Lines 23017 23035 +18
=========================================
+ Hits 22358 22376 +18
Misses 659 659 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
typecheck failing on refactor head and therefore also on this PR |
tejaskash
previously approved these changes
Aug 13, 2026
Hweinstock
reviewed
Aug 13, 2026
The CDK construct library rejects a CodeZip runtime that declares no
runtimeVersion, but our own ProjectRuntimeSchema marked the field plain
`.optional()`. The CLI therefore accepted a spec that synthesis would refuse,
and the user only found out after a compile and a synth.
Mirror the library's rule so the CLI reports it against agentcore.json instead.
Container builds take their version from the image and stay exempt, matching the
adjacent container-only-fields check.
Surfacing the rule earlier is only useful if it says what to fix, and
DeserializationError named the file and nothing else -- the zod issues were
reachable only from the debug log. It now takes an optional `detail`, which
json.read() fills with z.prettifyError(), so every caller of json.read()
reports the failing field rather than just the project manager:
Failed to deserialize file at ".../agentcore/agentcore.json"
✖ runtimeVersion is required for CodeZip builds
→ at runtimes[0].runtimeVersion
A JSON syntax error carries no zod issues to render and is unchanged.
Two test fixtures were CodeZip runtimes without runtimeVersion and are now
invalid by this rule, so they gain one.
notgitika
force-pushed
the
fix/codezip-runtime-version
branch
from
August 21, 2026 18:52
d7475e9 to
874a194
Compare
tejaskash
approved these changes
Aug 21, 2026
nborges-aws
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased onto current
refactor. Both parents (#1969, #1970) have merged, andrefactorhas since landed two of this PR's three parts independently — see "What the rebase changed" below.The gap
The CDK construct library's
AgentEnvSpecSchemarefines:Our copy of that schema marked the field plain
.optional(), with no such rule. So the CLI accepted a spec that synthesis would refuse, and the user only discovered it after a fulltsc+cdk synth— from a stack trace inside the generated app rather than from the CLI.Our
superRefinealready mirrors the library's checks almost one for one, including the identical container-only-fields loop directly beneath. This adds the one that was missing, in the same position the library has it:Container builds take their version from the image and stay exempt, consistent with the check below it.
Reporting the rule earlier is only useful if it says what to fix
DeserializationErrornamed the file and nothing else:The zod issues were attached as
cause, which nothing renders — they were reachable only from the debug log. So the user traded CDK's preciseruntimes[0].runtimeVersion: runtimeVersion is required for CodeZip buildsfor a message that doesn't name a field.DeserializationErrornow takes an optionaldetail, andjson.read()fills it withz.prettifyError():Putting it in
json.read()rather than in the project manager means every caller ofjson.read()benefits, not justagentcore.json. A JSON syntax error carries no zod issues, so that path is unchanged and still covered by its existing test.Blast radius
ProjectSpecSchemahas exactly one consumer:resolve()atmanager.tsx:56. So the only configs this newly rejects are ones the CDK app would also reject at synth — no workflow that previously succeeded starts failing. It does mean the whole CLI now refuses to load such a config rather than failing at build time, which is the intent.Two test fixtures were CodeZip runtimes without
runtimeVersionand are now invalid by this rule, so they gain one (projectSchemas/runtime.test.ts,projectSchemas/project.test.ts). Worth a look during review that the surrounding assertions still test what they claim — the security-group-cap test atruntime.test.tsasserts a CodeZip spec succeeds, so it would have silently started passing for the wrong reason had the fixture not been fixed.What the rebase changed
Two of the three original commits are now redundant, so the branch is a single commit:
DeserializationErrorto a USER-sourcedAgentCoreCLIErrorlanded onrefactorindependently. Only thedetailoption is new here.try/catchwrapper inresolve()also landed onrefactorindependently.manager.tsxis no longer touched by this PR at all.describeValidationFailurewithz.prettifyErrorand moved the detail intojson.ts(thanks @Hweinstock). That is the shape above; the intermediate commit no longer stood on its own after the rebase, so the two were squashed.Verification
Against the same real scaffolded project used to verify #1970, with
runtimeVersionremoved from itsagentcore.json:tscran,cdk synthran, then the construct library's zod error.runtimes[0].runtimeVersion— no compile, no synth, nonode_modulesneeded.New unit tests: the rule rejects a CodeZip runtime with no
runtimeVersionand reports it atpath: ["runtimeVersion"]; a container runtime without one still validates; andresolve()surfaces the reason in its message.bun test— 1600 pass, 2 fail. Both failures areCannot find package 'aws-cdk-lib'loading the CDK template assets (src/assets/cdk/test/cdk.test.ts), which are meant to run inside a scaffolded project and are unrelated to this diff.tsc --noEmitclean,oxlintclean,prettier --checkclean on all six touched files.